#include <qwidget>
#include <qpaintevent>
#include <qpainterpath>
#include <qpropertyanimation>
#include <qmouseevent>
#include <qlabel>

class CTLSlipBtn : public QWidget
{
    Q_OBJECT
public:
    CTLSlipBtn(QWidget *parent = 0);
    ~CTLSlipBtn();
    void setBtnChecked(bool check);
    bool isBtnChecked() const { return    m_bIsChecked; }
    void setStateOnString(const QString& str) { StateOn = str; }
    void setStateOffString(const QString& str) { StateOff = str; }

protected:
    void paintEvent(QPaintEvent* e);
    void mouseReleaseEvent(QMouseEvent * e);
    void resizeEvent(QResizeEvent *event);
signals:
    void sigClicked(bool);
private:
    void _checkBtn();
    int getFontSize(int w, int h);
    void init(int w, int h);

private slots:
    void MeAnimationValueChanged(const QVariant &value);
private:
    QLabel * m_pSwitchBtn;
    bool m_bIsChecked;
    QPainterPath* m_pTBtnBg;
    QPropertyAnimation* m_pBtnAni;
    QPixmap* m_BtnImg;
    QString StateOn;
    QString StateOff;
};